//
//  NSString+Extension.m
//  XLWeiBo-1.0
//
//  Created by lanou3g on 15/11/7.
//  Copyright © 2015年 崔丰帅. All rights reserved.
//

#import "NSString+Extension.h"

@implementation NSString (Extension)
- (CGSize)sizeWithFont:(UIFont *)font maxW:(CGFloat)maxW {
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = font;
    CGSize maxSize = CGSizeMake(maxW, MAXFLOAT);
    
    return [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}

- (CGSize)sizeWithFont:(UIFont *)font {
    return [self sizeWithFont:font maxW:MAXFLOAT];
    
    //    NSMutableDictionary *attrs = [[NSMutableDictionary alloc] init];
    //    attrs[NSFontAttributeName] = font;
    //    return [text sizeWithAttributes:attrs];
}
@end
